package com.cheyun.netsalev3.repository

import com.cheyun.netsalev3.bean.CarPinPaParam
import com.cheyun.netsalev3.utils.api.ApiCallback
import com.cheyun.netsalev3.utils.api.ApiClient
import com.cheyun.netsalev3.utils.api.ApiException
import com.cheyun.netsalev3.utils.api.BaseResp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlin.reflect.KFunction1

class ChooseCityRepository {
    /**
     * 地区数据-省市县区
     */
    fun getDistrict(type: Int, pid: Int, kFunction1: KFunction1<@ParameterName(name = "list") java.util.ArrayList<CarPinPaParam>, Unit>) {
        ApiClient.getInstance().getDistrict(type, pid)
                .subscribeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(object : ApiCallback<BaseResp<ArrayList<CarPinPaParam>>>() {
                    override fun onSuccess(t: BaseResp<ArrayList<CarPinPaParam>>) {
                        t.data?.apply {
                            kFunction1(this)
                        }
                    }

                    override fun onError(ex: ApiException) {

                    }


                })

    }
}